FROM {{ namespace }}/{{ image_prefix }}zun-base:{{ tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}

{% block zun_cni_daemon_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{% if base_package_type == 'rpm' %}

    {% set zun_cni_daemon_packages = [
        'openvswitch'
    ] %}

{% elif base_package_type == 'deb' %}

    {% set zun_cni_daemon_packages = [
        'bridge-utils',
        'openvswitch-switch'
    ] %}

{% endif %}
{{ macros.install_packages(zun_cni_daemon_packages | customizable("packages")) }}

{% block zun_cni_daemon_version %}
ARG zun_cni_daemon_version=0.7.1
ARG zun_cni_daemon_url=https://github.com/containernetworking/plugins/releases/download/v${zun_cni_daemon_version}/cni-plugins-{{debian_arch}}-v${zun_cni_daemon_version}.tgz
{% endblock %}

COPY zun_sudoers /etc/sudoers.d/kolla_zun_sudoers

RUN chmod 750 /etc/sudoers.d \
    && chmod 640 /etc/sudoers.d/kolla_zun_sudoers \
    && curl -o /tmp/cni-plugins.tgz ${zun_cni_daemon_url} \
    && tar -C /opt -xzvf /tmp/cni-plugins.tgz ./loopback \
    && rm -f /tmp/cni-plugins.tgz

{{ macros.kolla_patch_sources() }}

{% block zun_cni_daemon_footer %}{% endblock %}
{% block footer %}{% endblock %}
